<?php
/**
 * @author GhostWei
 * @date Aug 20, 2012
 */
class picture_special_topic_concept extends system_concept_abstract {
	
	public function __construct($lang) {
		parent::__construct(array('lang' => $lang), array('lang = ?' => $lang));
	}
	
	public function init() {
		$this->setModel('picture_special_topic_model', 'special_topic');
		$this->setModelCols('special_topic', array('lang', 'special_id', 'topic_id'));
	}

	public function save($row) {
		$row->set('topic_id', intval($row->get('topic_id')));
		$row->set('special_id', intval($row->get('special_id')));
		if(!system_setting_language::verify($row->getLang())) {
			throw new picture_exception("Language(SPECIAL-TOPIC) formation error.");
		}
		
		if($row->getTopicId() && $row->getSpecialId() && 
				!$this->fetch(array('topic_id' => $row->getTopicId(), 'special_id' => $row->getSpecialId()))) {
			$this->getModel('special_topic')->insert($row->getModelData('special_topic'));
		}
		return $row;
	}

}
